<template>
    <div>
<h1>登录</h1>
<a href="/AddKs">去科室新增</a>
<table class="table">
    <tbody>
        <tr>
            <td>账号</td>
            <td>
                <input type="text" v-model="data.names">
            </td>
        </tr>
        <tr>
            <td>密码</td>
            <td>
                <input type="password" v-model="data.pwd">
            </td>
        </tr>
        <tr>
            <td></td>
            <td>
                <input type="button" value="登录" class="btn btn-success" @click="Login">
            </td>
        </tr>
    </tbody>
</table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref } from 'vue';
import { useRouter } from 'vue-router';
var router=useRouter();
const data=ref({
    names:"",
    pwd:""
})

const Login=()=>{
    axios.get("/api/Login/GetLog",{params:data.value}).then(res=>{
        if(res.data.lid==-1)
    {
        alert("账号不存在");
        return;
    }
        if(res.data.lid==-2)
    {
        alert("密码错误");
        return;
    }
        if(res.data.lid>0)
    {
        alert("登陆成功");
        router.push({path:"/RoomXs"})
        
    }
    })
}

</script>

<style scoped>

</style>